package org.demo.patten.memento;

import java.util.Stack;

/**
 * @author zhuj
 * @date 2025/3/29
 * @apiNote
 */
public class EditorHistory {
    private Stack<EditorMemento> history = new Stack<>();
    public void save(Editor editor) {
        history.push(editor.save());
    }
    public void undo(Editor editor) {
        if (!history.isEmpty()) {
            editor.restore(history.pop());
        }
    }
}
